#pragma once

#include "base.h"
#include "Poco/Mutex.h"

using Poco::FastMutex;

template<typename Single> 
class SingleObject
{
public:
	SingleObject(void)
	{
		m_pSingle = NULL;
	}
	~SingleObject(void)
	{
		if (m_pSingle) delete m_pSingle;
	}
	Single* One()
	{
		FastMutex::ScopedLock lock(m_mutex);
		
		if (!m_pSingle)
		{
			m_pSingle = new Single;
		}
		return m_pSingle;
	}

private:
	Single*		m_pSingle;
	FastMutex   m_mutex;
};

